<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>查看会员信息列表</title>
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="stylesheet" type="text/css" href="../lib/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="../stylesheets/theme.css">
    <link rel="stylesheet" href="../lib/font-awesome/css/font-awesome.css">
    <script src="../lib/jquery-1.7.2.min.js" type="text/javascript"></script>
    <!-- Demo page code -->
    <style type="text/css">
        #line-chart {
            height: 300px;
            width: 800px;
            margin: 0px auto;
            margin-top: 1em;
        }

        .brand {
            font-family: georgia, serif;
        }

        .brand .first {
            color: #ccc;
            font-style: italic;
        }

        .brand .second {
            color: #fff;
            font-weight: bold;
        }
    </style>
    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <!-- Le fav and touch icons -->
    <link rel="shortcut icon" href="../assets/ico/favicon.ico">
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="../assets/ico/apple-touch-icon-144-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="../assets/ico/apple-touch-icon-114-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="../assets/ico/apple-touch-icon-72-precomposed.png">
    <link rel="apple-touch-icon-precomposed" href="../assets/ico/apple-touch-icon-57-precomposed.png">
</head>

<!--[if lt IE 7 ]>
<body class="ie ie6"> <![endif]-->
<!--[if IE 7 ]>
<body class="ie ie7 "> <![endif]-->
<!--[if IE 8 ]>
<body class="ie ie8 "> <![endif]-->
<!--[if IE 9 ]>
<body class="ie ie9 "> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<body class="">
<!--<![endif]-->
<!-- 头部导航栏 -->
<?php include '../html/top.php' ?>
<!-- 左边部分导航栏 -->
<?php include '../html/left.php'?>
<!-- 右边部分 -->
<div class="content">
    <ul class="breadcrumb">
        <li><a href="../index.php">读者信息</a> <span class="divider">/</span></li>
        <li class="active">查看会员信息列表</li>
    </ul>
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="btn-toolbar">
                <div class="btn-group">
                </div>
            </div>
            <div class="shousuo">
                <span>卡号：</span>
                <input type="text" name="phone">
                <input type="submit" value="搜索">
            </div>
            <div class="well">

                <table class="table">
                    <thead>
                    <tr>
                        <th>用户名</th>
                        <th>卡号</th>
                        <th>性别</th>
                        <th>身份证号码</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php
                    //连接数据库
                    if (empty($_GET['page']))
                        $_GET['page'] = 1;
                    //当前页码
                    $page = (int)$_GET['page'];
                    //6条数据
                    $number = 10;
                    //第几页
                    $index = ($page - 1) * $number;
                    //总页数
                    $total = 1;
                    try {
                        $db = new PDO('mysql:dbname=books;host=127.0.0.1','root','123456');
                        $statement = $db->prepare('select count(*) from user');
                        if ($statement->execute() === false)
                            throw new PDOException('语句执行失败！');
                        $count = (int)$statement->fetch()[0];

                        $total = $count / $number;
                        $total = ceil($total);

                        $statement = $db->prepare('select * from user limit '. $index . ',' . $number);
                        if ($statement->execute() === false)
                            throw new PDOException('语句执行失败2！');
                        $re = (int)$statement->fetchAll();

                        $result= $db->query('select * from user limit '. $index . ',' . $number);
                        $re=$result->fetchAll();
                        if($re){
                            foreach($re as $list){?>
                                <tr class="shuju">
                                    <td><?="$list[name]"; ?></td>
                                    <td><?="$list[phone]"; ?></td>
                                    <td><?="$list[sex]";?></td>
                                    <td><?="$list[cardID]";?></td>
                                    <td><?php
                                        if("$list[status]" ==1){
                                            echo "<span>未归还</span>";
                                        }else{
                                            echo "<span>已归还</span>";
                                        }
                                        ?>
                                    </td>
                                    <td>
                                        <a href="user.html"><i class="icon-pencil"></i></a>
                                        <a href="#myModal" role="button" data-toggle="modal"><i class="icon-remove"></i></a>
                                    </td>

                                    <div style="clear: both;"></div>
                                </tr>
                                <?php
                            }
                        }else{
                            echo "<script> alert('查询失败!'); location.href='searchUser.php';</script>";
                        }

                    } catch (PDOException $e) {
                        echo 'Connection failed';
                    }
                    ?>
                    </tbody>
                </table>
            </div>
            <div class="modal small hide fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h3 id="myModalLabel">Delete Confirmation</h3>
                </div>
                <div class="modal-body">
                    <p class="error-text"><i class="icon-warning-sign modal-icon"></i>是否删除？</p>
                </div>
                <div class="modal-footer">
                    <button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
                    <button class="btn btn-danger" data-dismiss="modal">删除</button>
                </div>
            </div>
            <footer>
                <div class="pagination">
                    <ul>
                        <li><a href="searchUser.php?page=1">首页</a></li>
                        <li><a href="searchUser.php?page=<?= ($page > 1) ? $page - 1 : 1 ?>">上一页</a></li>
                        <?php if ($total < 8) { ?>
                            <?php for ($i = 1; $i <= $total; $i++) { ?>
                                <li><a href="searchUser.php?page=<?= $i ?>"><?= $i ?></a></li>
                            <?php } ?>
                        <?php } else { ?>
                            <?php for ($i = 1; $i <= 1; $i++) { ?>
                                <li><a href="searchUser.php?page=<?= $page - $i ?>"><?= $page - $i ?></a></li>
                            <?php }
                        } ?>

                        <li><a href="searchUser.php?page=<?= ($page < $total) ? $page + 1 : $total ?>">下一页</a>
                        </li>
                        <li><a href="searchUser.php?page=<?= $total ?>">尾页</a></li>
                        <div style="clear: both;"></div>
                    </ul>
                </div>
            </footer>

        </div>
    </div>
</div>

<script src="../lib/bootstrap/js/bootstrap.js"></script>
<script type="text/javascript">
    $("[rel=tooltip]").tooltip();
    $(function () {
        $('.demo-cancel-click').click(function () {
            return false;
        });
    });
</script>

</body>
</html>


